package com.example.springbootdemo.modules.user.dao;

import com.example.springbootdemo.po.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: ShengXiaJia
 * @Date: 2020/2/17 15:51
 * @Description:
 */
public interface UserDao {

    @Insert("insert into test_user (name,age,phone,create_time,end_time) values (#{name},#{age},#{phone},#{createTime},#{endTime})")
    //技巧：保存对象，获取数据库自增id
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(User user);

    List<User> getAll();

    User getById(Integer id);

    @Update("UPDATE test_user SET name=#{name} WHERE id =#{id}")
    int update(User user);

    @Delete("DELETE FROM test_user WHERE id =#{id}")
    int delete(Integer id);

}
